#include <stdio.h>
#define MAXLENGTH 1010

int get_line(char[], int);
void reverse_line(char[], char[], int);

int main(int argc, char *argv[]) {
  char line[MAXLENGTH];
  char reversed_line[MAXLENGTH];
  int len;

  while ((len = get_line(line, MAXLENGTH)) > 0) {
    reverse_line(line, reversed_line, len);
    printf("original: %s\n", line);
    printf("reversed: %s\n", reversed_line);
  }

  return 0;
}

int get_line(char s[], int lim) {
  int c, i;

  for (i = 0; i < lim && (c = getchar()) != EOF && c != '\n'; i++) {
    s[i] = c;
  }
  if (c == '\n') {
    s[i] = '\0';
  }

  return i;
}

void reverse_line(char orig[], char rev[], int length) {
  for (int i = length - 1; i >= 0; i--) {
    rev[length - i - 1] = orig[i];
  }
}
